﻿package net.wangit.view.element.component;

import net.wangit.LabelUtil;
import net.wangit.Page;
import net.wangit.Row;
import net.wangit.context.ActionContext;
import net.wangit.support.ElementWriter;
import net.wangit.view.element.ElementComponent;

public final class TextAreaElement extends ElementComponent {

	private static final ElementWriter writer = new TextAreaElementWriter();
	private static final String VALID_STRING = "</textarea>";
	private int queryMode;

	public TextAreaElement() {
	}

	protected void configure(Row row) {
		queryMode = row.getInt("qm", 1);
	}

	protected ElementWriter getWriter() {
		return writer;
	}

	protected void cloneAfter(ActionContext actioncontext, Page page1) {
	}

	public int getQueryMode() {
		return queryMode;
	}

	public void validate(ActionContext ac, StringBuffer error, String value) {
		if (value.toLowerCase().indexOf(TextAreaElement.VALID_STRING) >= 0)
			error.append(LabelUtil.get(ac, "system", "validation.textarea"));
	}

}
